<?php
$head = APP_PATH.'app/views/head.html';
require_once($head);
?>
<body>
<nav>
    <?php
	$genno = isset($_GET['genno'])?$_GET['genno']:null;
	$isEdit = false;
	if(isset($_GET['zbno'])){
		$mzb = Zibei::findFirst('zibei_no="'.$_GET['zbno'].'"');
		$isEdit = true;
		echo '<a href="javascript:void(0);" class="crtzb_nav">字辈数据修改 | '.$mzb->zibei.'</a>';
		echo $this->tag->linkTo("Zibei/crtzibei?genno=".$mzb->gen_no, "新增字辈");//框架内路由
		echo $this->tag->linkTo(array(
			"Zibei/delzb?zbno=".$mzb->zibei_no, "删除",
			"id" => "delzb_nav"
		));//框架内路由
		echo $this->tag->linkTo("Zibei/index", "返回");//框架内路由
	}else echo $this->tag->linkTo("Zibei/index?genno=".$genno, "返回");//框架内路由
    ?>
</nav>
<div>
    <?php echo $this->tag->form(['Zibei/crtzibei','id'=>'crt_zibei']) ?>
	<p>
		<label for="zibei">字辈名</label>		
		<?php 
			if($isEdit){
				echo $this->tag->textField(array(
					"zibei",
					"value"=>$mzb->zibei
				));
				echo $this->tag->hiddenField(array(
					"zibei_no",
					"value"=>$mzb->zibei_no
				));
			}
			else echo $this->tag->textField("zibei");
		?>
	</p>
	<p>
		<label for="pinyin">拼音</label>
		<?php 
			if($isEdit) echo $this->tag->textField(array(
				"pinyin",
				"value"=>$mzb->pinyin
			));
			else echo $this->tag->textField("pinyin");
		?>
	</p>
	<p>
		
		<?php
		//echo $this->tag->select('parent_name');//数据库加载
		
		if($genno || $isEdit){
			//echo $this->tag->selectStatic(array('parent_name',['1'=>'云','2'=>'汉']));//静态数据
			if($isEdit){
				if(!empty($mzb->parent_no)) $this->tag->setDefault("parent_no", $mzb->parent_no);
				$genno = $mzb->gen_no;
			}
			echo '<label for="parent_no">父辈名</label><br>';
			echo $this->tag->select(array(//数据库加载
				'parent_no',
				Zibei::find('gen_no="'.$genno.'"'),
				"using"=>array("zibei_no","zibei"),
				"useEmpty" => true,
				'emptyText' => '选择父类字辈'
			));
			if($isEdit){
				$genno = $mzb->gen_no;
				echo $this->tag->hiddenField(array(
					"pzibei",
					"value" => $mzb->pzibei
				));
			}else{
				echo $this->tag->hiddenField("pzibei");
			}			
			echo $this->tag->hiddenField(array(
				"gen_no",
				"value" => $genno
			));
		}	
		?>
	</p>
	<p>
		<label for="remark">备注</label>
		<?php
			if($isEdit) echo $this->tag->textField(array(
				"remark",
				"value"=>$mzb->remark
			)); else echo $this->tag->textField("remark");
		?>
	</p>
	<p>
		<?php echo $this->tag->submitButton("提交") ?>
        <br>
        <span id="form_tip"></span>
	</p>
</form>
</diV>
</body>
</html>